<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTransactionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('transactions', function (Blueprint $table) {
            $table->id();
            $table->string('patent_sn', 50)->comment('专利号');
            $table->string('patent_name')->comment('专利名称');
            $table->string('buyer')->comment('受让方');
            $table->string('contact_person')->nullable()->comment('联系人');
            $table->string('contact_mobile')->nullable()->comment('联系电话');
            $table->float('amount', 12, 4)->comment('转让金额');
            $table->string('type')->comment('转让类型');
            $table->date('date')->nullable()->comment('转让日期');

            $table->integer('user_id')->comment('负责人ID');
            $table->integer('department_id')->comment('学院ID');

            $table->timestamps();

            $table->index('patent_sn');
            $table->index('user_id');
            $table->index('department_id');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('transactions');
    }
}
